<template>
    <div id="tag">
        <header>
            <div class="explain">
                <h1>Tags</h1>
                <div class="tag-list">
                    <p v-for="(items,index) in navList" :class="[name==items.name?'tag-active':'']" :key="index" @click="changeNav(items.name)">{{items.name}}</p>
                </div>
                <div class="tag-more" @click="showTagModel()">...</div>
            </div>
        </header>
        <archivesWrapper ref="archivesWrapper" />
        <div class="tag-model" v-show="isshowTagModel" @click="showTagModel()">
            <div class="tag-wrapper">
                <p class="tag-active">分类一</p>
                <p @click.stop="selectTag($event)">分类一</p>
            </div>
        </div>
    </div>
</template>

<script>
import archivesWrapper from '@/components/archivesWrapper'
export default {
    name: 'Tag',
    components: {
        archivesWrapper,
    },
    data() {
        return {
            name: 'Vue',
            isshowTagModel: false,
            navList: [],
            list: [],
            dayList: [
                { name: '十月', val: '10' },
                { name: '九月', val: '09' },
                { name: '八月', val: '08' },
                { name: '七月', val: '07' },
            ],
        }
    },
    mounted() {
        this.getTagList()
        if (this.$route.query.name) {
            this.name = this.$route.query.name
            console.log(this.name)
        }
        this.on()
    },
    methods: {
        showTagModel() {
            this.isshowTagModel = !this.isshowTagModel
        },
        selectTag(event) { },
        changeNav(v) {
            this.name = v
        },
        goDetail(v) {
            this.$router.push('/Details?id=' + v)
        },
        getTagList() {
            let _this = this
            this.$axios.get(this.$api.tagList).then(function (res) {
                _this.navList = res.data.data || []
            })
        },
        on() {
            this.$refs.archivesWrapper.getList()
        },
    },
}
</script>

<style scoped>
.tag-model {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.tag-wrapper {
    width: 70%;
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
        0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.tag-wrapper p {
    padding: 0 15px;
    margin: 5px;
    line-height: 32px;
    cursor: pointer;
}
.tag-active {
    color: #fff;
    background: #ff4081;
    border-radius: 0.2em;
}
.explain {
    position: relative;
}
.tag-more {
    position: absolute;
    bottom: 0px;
    right: 0px;
    background: #3f51b5;
    width: 60px;
    text-align: center;
    line-height: 40px;
    height: 44px;
    cursor: pointer;
}
header {
    padding: 100px 15px !important;
}
.tag-list {
    display: flex;
    height: 44px;
    margin-top: 8px;
    line-height: 44px;
    overflow: hidden;
    flex-wrap: wrap;
}
.tag-list p {
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.8);
}
.tag-list p:hover {
    cursor: pointer;
}
.tag-active {
    border-bottom: 2px solid #ff4081;
}
</style>
